﻿var request = require('request');
var fs = require("fs");

function getWeAppQRDecode(weapp_id, weapp_secret, weapp_url, cb) {
 
    request.post({
        url: 'http://cli.im/home/weapp/create',
        form: {
            weapp_id: weapp_id,
            weapp_secret: weapp_secret,
            weapp_url: weapp_url
        }
    }, function(err, httpResponse, body) {
        if (err) {
            console.log(err)
            return;
        }
        let qrcode_image_url = JSON.parse(body).data;
        request.post({
            url: 'http://cli.im/Api/Browser/deqr',
            form: {
                data: qrcode_image_url
            }
        }, function(err, httpResponse, body) {
            if (err) {
                console.log(err);
                cb(null);
            }
            var result = JSON.parse(body).data.RawData;
            cb(result)
        })
    })
}









